package com.qinglei.recoup.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qinglei.recoup.system.dao.BreathAnalysisMapper;
import com.qinglei.recoup.system.domain.BreathAnalysis;
import com.qinglei.recoup.system.domain.SleepAnalysis;
import com.qinglei.recoup.system.dao.SleepAnalysisMapper;
import com.qinglei.recoup.system.service.SleepAnalysisService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * @author dqh
 */
@Service
public class SleepAnalysisServiceImpl extends ServiceImpl<SleepAnalysisMapper, SleepAnalysis> implements SleepAnalysisService {

    @Resource
    SleepAnalysisMapper SleepAnalysisMapper;
    @Override
    public List<SleepAnalysis> getSleepAnalysisList(LocalDate date) {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        if(!Objects.isNull(date)){
            yesterday = date;
        }
        List<SleepAnalysis> sleepAnalyses = SleepAnalysisMapper.selectList(Wrappers.<SleepAnalysis>lambdaQuery().eq(SleepAnalysis::getDate, yesterday));
        return sleepAnalyses;
    }


}
